﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.ProviderManageCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.ProviderManageHandler
{
    public class ProviderManageFindHandler:IRequestHandler<ProviderManageFindCommand,Results<ProviderManage>>
    {
        private readonly IProviderManageService _providerService;
        
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="providerService"></param>
        public ProviderManageFindHandler(IProviderManageService providerService)
        {
            _providerService = providerService;
        }
        /// <summary>
        /// 获取单条数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<ProviderManage>> Handle(ProviderManageFindCommand request, CancellationToken cancellationToken)
        {
            return Results<ProviderManage>.DataResult(await _providerService.GetProviderManageInfo(request.ProviderId));
        }
    }
}
